Skip to content

Conversation

AlexeySachkov
Copy link
Contributor

This is a cherry-pick of #20229

Problem
SYCL RT loads libur_adapter_opencl.so
(

"OpenCL", "libur_adapter_opencl.so", #FN)(__VA_ARGS__))
) while UR loads libur_adapter_opencl.so.0
(
MAKE_LIBRARY_NAME("ur_adapter_opencl", "0"),
). Note that SYCL RT calls dlopen() with RTLD_NOLOAD flag, which causes dlopen() to fail if this library wasn’t loaded before.

Now, in our Linux compiler packages, libur_adapter_opencl.so and libur_adapter_opencl.so.0 are symlinked so they are the same file, that’s why call to dlopen() in SYCL RT succeeds. However, the problem happens with DPCPP PyPi package, which doesn’t support symlinked files, so call to dlopen() fails because these are two different files.

Proposed solution
Lookup libur_adapter_opencl.so.0 as fallback.

Other potential solutions

  1. Why not just load libur_adapter_opencl.so.0 always? Because that causes SYCL unit tests, which rely on mocked OpenCL adapter to fail. In unit tests, we actually want SYCL RT to load libur_adapter_opencl.so (mocked) and UR to load libur_adapter_opencl.so.0, both of which are different files.
  2. Why not remove RTLD_NOLOAD flag? When using PyPi package, that can cause SYCL RT and UR to load two OpenCL adapters libraries. I'm not an expert on loaders, but that might lead to more bugs if, for example, OpenCL adapter functions that SYCL RT calls have side effects.

)

**Problem**
SYCL RT loads `libur_adapter_opencl.so`
(https://github.com/intel/llvm/blob/0ff1a5c2b4e4bc56799ec2dd17a89c3c57608890/sycl/include/sycl/detail/os_util.hpp#L129)
while UR loads `libur_adapter_opencl.so.0`
(https://github.com/intel/llvm/blob/0031df16e41bd0665e85af635b7bfd4e187ce7cd/unified-runtime/source/loader/ur_manifests.hpp#L35).
Note that SYCL RT calls `dlopen()` with `RTLD_NOLOAD` flag, which causes
`dlopen()` to fail if this library wasn’t loaded before.

Now, in our Linux compiler packages, `libur_adapter_opencl.so` and
`libur_adapter_opencl.so.0` are symlinked so they are the same file,
that’s why call to `dlopen()` in SYCL RT succeeds. However, the problem
happens with DPCPP PyPi package, which doesn’t support symlinked files,
so call to dlopen() fails because these are two different files.

**Proposed solution**
Lookup `libur_adapter_opencl.so.0` as fallback.

**Other potential solutions**
1. Why not just load `libur_adapter_opencl.so.0` always? Because that
causes SYCL unit tests, which rely on mocked OpenCL adapter to fail. In
unit tests, we actually want SYCL RT to load `libur_adapter_opencl.so`
(mocked) and UR to load `libur_adapter_opencl.so.0`, both of which are
different files.
2. Why not remove `RTLD_NOLOAD` flag? When using PyPi package, that can
cause SYCL RT and UR to load two OpenCL adapters libraries. I'm not an
expert on loaders, but that might lead to more bugs if, for example,
OpenCL adapter functions that SYCL RT calls have side effects.
@AlexeySachkov
Copy link
Contributor Author

Despite pre-commit results looking scary, there are only two failures:

Failed Tests (2):
  SYCL :: Basic/out_of_order_queue_status_khr_empty.cpp
  SYCL :: SeparateCompile/test.cpp

The second one is a known infrastructure issues and it is unrelated to the PR.
The first one is a known tests issue that is being tracked internally as CMPLRTST-27639 - there is a race condition in the test, making it sometimes produce incorrect results.

Considering the above, I will proceed with merge

@AlexeySachkov AlexeySachkov merged commit dcde89d into intel:sycl-rel-6_3 Oct 16, 2025
16 of 23 checks passed
@AlexeySachkov AlexeySachkov deleted the private/asachkov/cherry-pick-20229 branch October 16, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants